﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterSGA.Master" AutoEventWireup="true" CodeBehind="Role.aspx.cs" Inherits="SGA.Authentication.Admin.Role" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ajaxToolkit:ToolkitScriptManager ID="ScriptManager" runat="server"></ajaxToolkit:ToolkitScriptManager>
    <div class="container-fluid">
        <div class="row">
            <!-- Start: Data source -->
            <asp:EntityDataSource ID="EDSAccessRole" runat="server" ConnectionString="name=MailingEntities" DefaultContainerName="MailingEntities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="False" EntitySetName="AccessRoles">
            </asp:EntityDataSource>
            <!-- End: Data source -->

            <div class="col-lg-3">
                <div class="form-group">
                    <asp:ListView ID="LVAccessRoles" runat="server" DataSourceID="EDSAccessRole" OnItemDeleting="LVAccessRoles_ItemDeleting" OnItemInserting="LVAccessRoles_ItemInserting" DataKeyNames="Id" InsertItemPosition="FirstItem">
                        <InsertItemTemplate>
                            <ajaxToolkit:HoverMenuExtender ID="HoverMenu" runat="server"
                                PopupControlID="PopupMenu"
                                PopupPosition="Right"
                                TargetControlID="PopupRow"
                                PopDelay="50" HoverDelay="20" OffsetX="10" />
                            <tr runat="server" id="PopupRow">
                                <td>
                                    <asp:TextBox ID="RoleTextBox" CssClass="form-control" runat="server" Text='<%# Bind("Role") %>' />
                                    <asp:RequiredFieldValidator ID="RequiredFieldRole" runat="server" ErrorMessage="O nível de acesso é obrigatório." CssClass="Alert" Display="Dynamic" ControlToValidate="RoleTextBox" SetFocusOnError="True" ValidationGroup="InsertItem"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <asp:Panel ID="PopupMenu" runat="server" Width="200" Style="display: none">
                                <div class="panel panel-default">
                                    <div class="panel-heading">Inserir novo nível de acesso</div>
                                    <div class="panel-body">
                                        <asp:LinkButton ID="LinkButtonInsert" runat="server" Text="Adicionar" CommandName="Insert" ValidationGroup="InsertItem"></asp:LinkButton>
                                        <br />
                                        <asp:LinkButton ID="LinkButtonCancel" runat="server" Text="Cancelar" CommandName="Cancel" CausesValidation="false"></asp:LinkButton>
                                    </div>
                                </div>
                            </asp:Panel>
                        </InsertItemTemplate>

                        <EmptyDataTemplate>
                            <table runat="server" class="EmptyData">
                                <tr>
                                    <td>Sem dados.</td>
                                </tr>
                            </table>
                        </EmptyDataTemplate>

                        <ItemTemplate>
                            <ajaxToolkit:HoverMenuExtender ID="HoverMenu" runat="server"
                                PopupControlID="PopupMenu"
                                PopupPosition="Right"
                                TargetControlID="PopupRow"
                                PopDelay="50" HoverDelay="20" OffsetX="10" />

                            <tr runat="server" id="PopupRow">
                                <td>
                                    <asp:Label ID="RoleLabel" runat="server" Text='<%# Eval("Role") %>' />
                                </td>
                            </tr>
                            <asp:Panel ID="PopupMenu" runat="server" Width="200" Style="display: none">
                                <div class="panel panel-default">
                                    <div class="panel-heading"><%# Eval("Role")%></div>
                                    <div class="panel-body">
                                        <asp:LinkButton ID="LinkButtonDelete" runat="server" Text="Remover" CommandName="Delete" CommandArgument='<%#Eval("Id") %>' OnClientClick="javascript:return confirm('Deseja remover o utilizador?')"></asp:LinkButton>
                                    </div>
                                </div>
                            </asp:Panel>
                        </ItemTemplate>

                        <LayoutTemplate>
                            <table runat="server" class="table table-hover table-bordered">
                                <tr runat="server">
                                    <th>Nível de acesso</th>
                                </tr>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </LayoutTemplate>
                    </asp:ListView>
                </div>
            </div>
            <div id="divStatus">
                <asp:Label ID="NotificationLabel" runat="server"></asp:Label>
            </div>
        </div>
    </div>
</asp:Content>
